<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	ArrayList<String> jsPaths = (ArrayList<String>) request.getAttribute("jsPaths");
	jsPaths.add("/resources/bootstrap/table/jquery.dataTables.min.js");
	jsPaths.add("/resources/bootstrap/table/dataTables.bootstrap.js");
	jsPaths.add("/resources/custom/target/target.js");
	jsPaths.add("/resources/bootstrap/dynatree/jquery-ui.custom.js");
	jsPaths.add("/resources/bootstrap/dynatree/jquery.cookie.js");
	jsPaths.add("/resources/bootstrap/dynatree/jquery.dynatree.js");
	jsPaths.add("/resources/bootstrap/dist/js/typeahead.js");
	jsPaths.add("/resources/bootstrap/dist/js/fileInput.js");
	jsPaths.add("/resources/bootstrap/select/bootstrap-select.js");
%>
<div class="panel-group" id="accordion">
	<div class="panel panel-default">
		<div class="panel-heading">
			<h4 class="panel-title">
				<div data-toggle="collapse" data-toggle="collapse"
					data-parent="#accordion" href="#collapseOne"
					style="cursor: pointer;">
					<img alt=""
						src="${pageContext.request.contextPath}/resources/bootstrap/custom/search.png">
					&nbsp;搜索用户<span class="glyphicon glyphicon-chevron-down pull-right"
						id="arrow"></span>
				</div>
			</h4>
		</div>
		<div id="collapseOne" class="panel-collapse collapse">
			<div class="panel-body">
				<form role="form">
					<div class="row">
						<div class="form-group col-sm-4">
							<label for="searchBuilding" class="col-sm-4 control-label">楼号:</label>
							<div class="col-sm-8">
								<input name="searchBuilding" id="searchBuilding"
									class="form-control suggestBuilding" placeholder="楼号">
							</div>
						</div>
						<div class="form-group col-sm-4">
							<label for="searchDoor" class="col-sm-4 control-label">门号:</label>
							<div class="col-sm-8">
								<input name="searchDoor" id="searchDoor"
									class="form-control suggestDoor" placeholder="门号">
							</div>
						</div>
						<div class="form-group col-sm-4">
							<label for="searchUser" class="col-sm-4 control-label">户号:</label>
							<div class="col-sm-8">
								<input name="searchUser" id="searchUser"
									class="form-control suggestUser" placeholder="户号">
							</div>
						</div>
					</div>
					<div class="row">
						<div class="form-group col-sm-4">
							<label for="searchProjectName" class="col-sm-4 control-label">项目:</label>
							<div class="col-sm-8">
								<input name="searchProjectName" id="searchProjectName"
									class="form-control suggestProject" placeholder="项目名称">
							</div>
						</div>
						<div class="form-group col-sm-4">
							<label for="searchProjectName" class="col-sm-4 control-label">用户标识:</label>
							<div class="col-sm-8">
								<input name="searchKey" id="searchKey"
									class="form-control suggestKey" placeholder="用户标识">
							</div>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<button class="btn btn-success btn-sm" data-toggle="modal"
	id="addTarget">添加用户</button>
<button class="btn btn-success btn-sm" data-toggle="modal"
	id="uploadTarget">批量导入</button>
<div class="table-responsive">
	<table id="target"
		class="table table-striped table-bordered table-hover display"
		cellspacing="0" width="100%">
		<thead>
			<tr>
				<th>项目名称</th>
				<th>楼号</th>
				<th>门号</th>
				<th>户号</th>
				<th>用户标识</th>
				<th>用户姓名</th>
				<th>联系电话</th>
				<th>操作</th>
			</tr>
		</thead>
	</table>
</div>

<!-- add project dialog -->
<div class="modal fade" id="createTargetModal" tabindex="-1"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<!--  button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>-->
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">用户</h4>
			</div>

			<form id="addForm" class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/target/create"
				method="post">
				<div class="modal-body">
					<div class="form-group">
						<label for="projectName" class="col-sm-3 control-label">项目名称</label>
						<div class="col-sm-9" id="treeFather">
							<input type='hidden' class="form-control" id="projectId"
								name="projectId"> <input type='text'
								class="form-control" id="projectName" name="projectName"
								placeholder="项目名称">
							<div id="tree" class="panel panel-primary tree"></div>
						</div>
					</div>
					<div class="form-group">
						<label for="building" class="col-sm-3 control-label">楼号</label>
						<div class="col-sm-9">
							<input type="text" class="form-control suggestBuilding"
								id="building" name="building" placeholder="楼号">
						</div>
					</div>
					<div class="form-group">
						<label for="door" class="col-sm-3 control-label">门号</label>
						<div class="col-sm-9">
							<input type="text" class="form-control suggestDoor" id="door"
								name="door" placeholder="门号">
						</div>
					</div>
					<div class="form-group">
						<label for="user" class="col-sm-3 control-label">户号</label>
						<div class="col-sm-9">
							<input class="form-control suggestUser" id="user" name="user"
								placeholder="户号">
						</div>
					</div>
					<div class="form-group">
						<label for="key" class="col-sm-3 control-label">用户标识</label>
						<div class="col-sm-9">
							<input class="form-control suggestKey" id="key" name="key"
								placeholder="用户标识">
						</div>
					</div>
					<div class="form-group">
						<label for="name" class="col-sm-3 control-label">用户姓名</label>
						<div class="col-sm-9">
							<input class="form-control" id="name" name="name"
								placeholder="用户姓名">
						</div>
					</div>
					<div class="form-group">
						<label for="telephone" class="col-sm-3 control-label">联系电话</label>
						<div class="col-sm-9">
							<input class="form-control" id="telephone" name="telephone"
								placeholder="联系电话">
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary" id="create">创建用户</button>
				</div>
			</form>
		</div>
	</div>
</div>
<!-- edit user dialog -->
<div class="modal fade" id="editTargetModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">编辑用户</h4>
			</div>

			<form id="editForm" class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/target/update"
				method="post">
				<div class="modal-body">
					<input type="hidden" id="idEdit" name="id"> <input
						type="hidden" id="projectIdEdit" name="projectId">
					<div class="form-group">
						<label for="projectNameEdit" class="col-sm-3 control-label">项目名称</label>
						<div class="col-sm-9" id="treeFather">
							<input type='text' class="form-control" id="projectNameEdit"
								name="projectName" placeholder="项目名称">
							<div id="treeEdit" class="panel panel-primary tree"></div>
						</div>
					</div>
					<div class="form-group">
						<label for="buildingEdit" class="col-sm-3 control-label">楼号</label>
						<div class="col-sm-9">
							<input type="text" class="form-control suggestBuilding"
								id="buildingEdit" name="building" placeholder="楼号">
						</div>
					</div>
					<div class="form-group">
						<label for="doorEdit" class="col-sm-3 control-label">门号</label>
						<div class="col-sm-9">
							<input type="text" class="form-control suggestDoor" id="doorEdit"
								name="door" placeholder="门号">
						</div>
					</div>
					<div class="form-group">
						<label for="userEdit" class="col-sm-3 control-label ">户号</label>
						<div class="col-sm-9">
							<input class="form-control suggestUser" id="userEdit" name="user"
								placeholder="户号">
						</div>
					</div>
					<div class="form-group">
						<label for="keyEdit" class="col-sm-3 control-label ">用户标识</label>
						<div class="col-sm-9">
							<input class="form-control suggestKey" id="keyEdit" name="key"
								placeholder="用户标识">
						</div>
					</div>
					<div class="form-group">
						<label for="nameEdit" class="col-sm-3 control-label">用户姓名</label>
						<div class="col-sm-9">
							<input class="form-control" id="nameEdit" name="name"
								placeholder="用户姓名">
						</div>
					</div>
					<div class="form-group">
						<label for="telephoneEdit" class="col-sm-3 control-label">联系电话</label>
						<div class="col-sm-9">
							<input class="form-control" id="telephoneEdit" name="telephone"
								placeholder="联系电话">
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">更新</button>
				</div>
			</form>
		</div>
	</div>
</div>
<!-- delete user dialog -->
<div class="modal fade" id="deleteTargetModal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title">删除用户</h4>
			</div>
			<div class="modal-body">
				<p>确定永久删除该条记录吗？</p>
			</div>
			<form class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/target/delete"
				method="post">
				<input type="hidden" class="form-control" id="idDelete" name="id">

				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">删除</button>
				</div>
			</form>
		</div>
	</div>
</div>

<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">导入用户</h4>
			</div>
			<form id="uploadForm" class="form-horizontal" role="form"
				action="${pageContext.request.contextPath}/target/upload"
				method="post" enctype="multipart/form-data">
				<div class="modal-body">
					<input type="hidden" id="projectIdUpload" name="projectId">
					<div class="form-group">
						<label for="projectNameUpload" class="col-sm-3 control-label">项目名称</label>
						<div class="col-sm-9" id="treeFather">
							<input type='text' class="form-control" id="projectNameUpload"
								name="projectName" placeholder="项目名称">
							<div id="treeUpload" class="panel panel-primary tree"></div>
						</div>
					</div>

					<div class="form-group">
						<label for="file" class="col-sm-3 control-label">文件名</label>
						<div class="col-sm-9">
							<input type="file" class="form-control" id="file" name="file"
								title="请选择用户文件">
						</div>
					</div>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button type="submit" class="btn btn-primary">导入</button>
				</div>
			</form>
		</div>
	</div>
</div>